package com.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zjl.daoImpl.ManageDaoImpl;
import com.zjl.daoImpl.StudentDaoImpl;


/**
 * Servlet implementation class SchoolManageServlet
 */
public class SchoolManageServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public SchoolManageServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see Servlet#init(ServletConfig)
	 */
	public void init(ServletConfig config) throws ServletException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see Servlet#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		StudentDaoImpl mvp=new StudentDaoImpl();
		ManageDaoImpl ivp=new ManageDaoImpl();
		System.out.println("************************************************");
		System.out.println("****************欢迎学生信息管理系统*************");
		System.out.println("************************************************");
		//声明 scanner 
		Scanner scanner=new Scanner(System.in);
		int num;
		int num1;
		int num2;
		//声明变量0
		do {
			//变量接收录入按键
			System.out.println( "***1.系统管理***"+"\n"+
						        "***2.学籍信息管理***"+"\n"+
								"***3.班级信息管理*** "+"\n"+
						        "***4.成绩信息管理***"+"\n"+ 
						        "***5.课程信息管理***"+"\n"+ 
								"***0.退出系统***");
			System.out.println("请输入您选择的功能:");
			num=scanner.nextInt();
			switch (num) {
			case 1:
				    do {
							System.out.println( "***1.查看管理员信息***"+"\n"+
										        "***2.增加管理员***"+"\n"+
										        "***3.修改管理员***"+"\n"+
										        "***4.删除管理员***"+"\n"+
												"***0.退出系统管理功能***");
							System.out.println("请输入您选择的功能:");
							num1=scanner.nextInt();
							switch (num1) {
							case 1:
								ivp.showALL();
								break;
							case 2:
								ivp.addmana();
								break;
                            case 3:
                            	ivp.manaUpdate();
								break;
							case 4:
								ivp.deletemana();
								break;
							}
					} while (num1!=0);
					System.out.println("谢谢使用!");
				break;
			case 2:
				do {
					System.out.println( "***1.查看学生信息***"+"\n"+
								        "***2.增加学生信息***"+"\n"+
								        "***3.修改学生信息***"+"\n"+
								        "***4.删除学生信息***"+"\n"+
										"***0.退出系统管理功能***");
					System.out.println("请输入您选择的功能:");
					num2=scanner.nextInt();
					switch (num2) {
					case 1:
						mvp.showALL();
						break;
					case 2:
						mvp.addStudent();
						break;
					case 3:
						mvp.StudentUpdate();
						break;
					case 4:
						mvp.deleteStudent();
						break;
					}
			} while (num2!=0);
			System.out.println("谢谢使用!");
				break;
			case 3:
				
				break;
			case 4:
				
				break;
            case 5:
				
				break;
			}
		} while (num!=0);
		System.out.println("谢谢使用!");
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		//doGet(request, response);
			
		}

}
